package com.project.oj.judge;

import com.project.oj.judge.strategy.*;
import com.project.oj.judge.codesandbox.model.JudgeInfo;
import com.project.oj.model.entity.QuestionSubmit;
import org.springframework.stereotype.Service;


@Service
public class JudgeManager {

    JudgeInfo doJudge(JudgeContext judgeContext) {
        QuestionSubmit questionSubmit = judgeContext.getQuestionSubmit();
        String language = questionSubmit.getLanguage();
        JudgeStrategy judgeStrategy = new DefaultJudgeStrategy();;
        if ("java".equals(language)) {
            judgeStrategy = new JavaLanguageJudgeStrategy();
        }
        if ("cpp".equals(language)) {
            judgeStrategy = new CppLanguageJudgeStrategy();
        }if ("python".equals(language)) {
            judgeStrategy = new PythonLanguageJudgeStrategy();
        }
        return judgeStrategy.doJudge(judgeContext);
    }

}
